//
// Created by LoveHoneyYou on 2024-11-16.
//

#include "Channel.h"
Channel::Channel(int fd, const FD_Event &event, const Channel::HandleFunc &read_func, const Channel::HandleFunc &write_func,
                 const Channel::HandleFunc &destory_func, void *args)
                :fd_(fd)
                ,event_((int)event)
                ,read_callback_(read_func)
                ,write_callback_(write_func)
                ,destroy_callback_(destory_func)
                ,args_(args)
{
}


void Channel::Write_Event_Enable(bool flag)
{
    if(flag)
    {
        event_ |= (int)(FD_Event::WriteEvent);
    }
    else
    {
        event_ = event_ & ~(int)FD_Event::WriteEvent;
    }
}


bool Channel::Is_Check_Write_Event()
{
    return event_ & (int)FD_Event::WriteEvent;
}
